\name{pp3multitype}
\alias{pp3multitype}
\title{Create a Multitype 3D Point Pattern}
\description{
  Creates a multitype three-dimensional point pattern object.
}
\usage{
  pp3multitype(X, marks, \dots)
}
\arguments{
  \item{X}{A point pattern (object of class \code{pp3}).}
  \item{marks}{Optional vector of marks. If missing, the existing marks of \code{X} are used.}
  \item{\dots}{Additional arguments passed to methods.}
}
\value{
  An object of class \code{pp3multitype} which inherits from \code{pp3}.
}
\details{
  This function creates a multitype 3D point pattern object. It ensures that
  the marks are a factor with at least two levels, which is required for
  multitype analysis functions like \code{pcfcross3D}.
  
  If \code{marks} is provided, it will be converted to a factor if necessary.
  If \code{marks} is missing, the existing marks of \code{X} will be used.
  
  The function checks that there are at least two distinct mark levels.
}
\seealso{
  \code{\link{is.multitype.pp3}} for checking if a pattern is multitype,
  \code{\link{pcfcross3D}} for cross-type pair correlation function.
}
\examples{
  \dontrun{
  if(require(spatstat.geom)) {
    # Create a 3D point pattern
    box <- box3(xrange=c(0,1), yrange=c(0,1), zrange=c(0,1))
    coords <- matrix(runif(300), ncol=3)
    
    # Create with marks
    marks <- sample(c("A", "B"), 100, replace=TRUE)
    X <- pp3(x=coords[,1], y=coords[,2], z=coords[,3], domain=box)
    
    # Convert to multitype
    X_multi <- pp3multitype(X, marks=marks)
    print(X_multi)
  }
  }
}